import cv2
import numpy as np

url = "rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid"
cap = cv2.VideoCapture(url)
cnt = 0;

while True:  
        ret, img = cap.read()
        if not ret:  
                print("err: capture read")
                break  

        # 在这里可以对 img 进行处理，例如显示图像
        # cv2.imshow('Frame', img)

        if not cnt:
                width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
                height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
                fps = cap.get(cv2.CAP_PROP_FPS)
                print("width  =", width)
                print("height =", height)
                print("fps    =", fps)
                print("ndim   =", img.ndim)
                print("shape  =", img.shape)
                print("size   =", img.size)
                print("dtype  =", img.dtype)
                break

        cnt = cnt + 1

        # 按 'q' 键退出循环
        if cv2.waitKey(1) & 0xFF == ord('q'):
                break

# 释放资源和关闭窗口
cap.release()
cv2.destroyAllWindows()
